﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PMS
{
    public partial class frmUserPrize : Form
    {
        DBOperate operate = new DBOperate();
        public frmUserPrize()
        {
            InitializeComponent();
        }

        private void frmUserPrize_Load(object sender, EventArgs e)
        {
            string getJFstr =
                "select UserID as '员工编号',UserName as '员工姓名',UserDep as '所属部门',UserJF as '奖/罚',UserJFcontent as '奖罚内容',UserJFMoney as '奖励金额',UserFKMoney as '罚款金额',UserJFDate as '奖罚日期',UserCXDate as '撤销日期' from tb_prize";
            operate.BindDataGridView(dataGridView1, getJFstr);
        }

        private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if(dataGridView1.SelectedCells.Count == 0)
            {
                MessageBox.Show("请选择要删除的信息", "提示",                          //弹出消息对话框
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;                                                                //退出事件
            }
            else
            {
                string id = dataGridView1.SelectedCells[0].Value.ToString();           //获取员工编号
                string sql =                                                           //创建SQL字符串
                    "delete from tb_prize where UserID='" + id + "'";
                operate.OperateData(sql);                                              //删除奖罚信息
                MessageBox.Show("删除成功", "提示", MessageBoxButtons.OK,
                    MessageBoxIcon.Information);
            }
        }

        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            string id = dataGridView1.SelectedCells[0].Value.ToString();        //得到ID
            string name = dataGridView1.SelectedCells[1].Value.ToString();      //得到名称
            frmChangePrize prize = new frmChangePrize();                        //创建更改奖罚窗体对象
            prize.Uid = id;
            prize.Uname = name;
            prize.ShowDialog();
        }


    }
}
